package com.bjbn.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bjbn.entity.Organize;
import com.bjbn.entity.UserRelation;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;


@Mapper
public interface UserRelationMapper extends BaseMapper<UserRelation> {

    @Insert("INSERT INTO base_user_relation(f_id, f_user_id, f_object_type, f_object_id,   f_creator_time, f_creator_user_id, f_last_modify_time, f_last_modify_user_id, f_tenant_id) " +
            "VALUES(#{userRelation.id}, #{userRelation.userId}, #{userRelation.objectType}, #{userRelation.objectId}, #{userRelation.creatorTime},#{userRelation.creatorUserId},#{userRelation.lastModifyTime},#{userRelation.lastModifyUserId},#{userRelation.tenantId}) " +
            "ON CONFLICT (f_id,f_tenant_id) DO UPDATE SET " +
            "f_user_id = EXCLUDED.f_user_id, " +
            "f_object_type = EXCLUDED.f_object_type," +
            "f_object_id = EXCLUDED.f_object_id , " +
            "f_last_modify_time = EXCLUDED.f_last_modify_time, " +
            "f_last_modify_user_id = EXCLUDED.f_last_modify_user_id")
    int insertOrUpdate(@Param("userRelation") UserRelation userRelation);

}
